<?php
//$this->breadcrumbs=array(
//	UserModule::t('Users')=>array('admin'),
//	$model->username,
//);
$this->mainTitle = UserModule::t('View User');
?>
<h1><?php echo $this->mainTitle . ' "' . $model->username . '"'; ?></h1>

<?php
$this->menu = array(
    array('label' => UserModule::t('Manage User'), 'url' => array('admin')),
    array('label' => UserModule::t('Manage Profile Field'), 'url' => array('profileField/admin')),
    array('label' => UserModule::t('Create User'), 'url' => array('create')),
    array('label' => UserModule::t('Update User'), 'url' => array('update', 'id' => $model->id)),
    array('label' => UserModule::t('Delete User'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => UserModule::t('Are you sure to delete this item?'))),
    array('label' => UserModule::t('List User'), 'url' => array('/user')),
    array('label' => UserModule::t('Manage User'), 'url' => array('admin')),
    array('label' => UserModule::t('Manage Profile Field'), 'url' => array('profileField/admin')),
);

$attributes = array(
    'id',
    'username',
);

$profileFields = ProfileField::model()->forOwner()->sort()->findAll();
if ($profileFields) {
    foreach ($profileFields as $field) {
        array_push($attributes, array(
            'label' => UserModule::t($field->title),
            'name' => $field->varname,
            'type' => 'raw',
            'value' => (($field->widgetView($model->profile)) ? $field->widgetView($model->profile) : (($field->range) ? Profile::range($field->range, $model->profile->getAttribute($field->varname)) : $model->profile->getAttribute($field->varname))),
        ));
    }
}

array_push($attributes, 'password', 'email', 'activkey', array(
    'name' => 'createtime',
    'value' => date("d.m.Y H:i:s", $model->createtime),
        ), array(
    'name' => 'lastvisit',
    'value' => (($model->lastvisit) ? date("d.m.Y H:i:s", $model->lastvisit) : UserModule::t("Not visited")),
        ), array(
    'name' => 'superuser',
    'value' => $model->role->itemname,
        ), array(
    'name' => 'status',
    'value' => User::itemAlias("UserStatus", $model->status),
        )
);

$this->widget('zii.widgets.CDetailView', array(
    'data' => $model,
    'attributes' => $attributes,
));

echo CHtml::button(Util::t('Update'), array(
    'onClick' => 'window.location="'.CController::createUrl('admin/update', array('id' => $model->id)).'"',
));
?>
